package Offer;

import java.util.Arrays;

/**
 * 把数字翻译成字符串
 * @author 是阿秋啊
 * @date 2022/04/08 20:50
 **/
public class Num46 {
    public int translateNum(int num) {
        if (num < 10) {
            return 1;
        }
        if (num < 26) {
            return 2;
        }
        int a = 1;
        int b = 1;
        String str = String.valueOf(num);
        for (int i = 2; i <= str.length(); i++) {
            String temp = str.substring(i - 2, i);
            int c = temp.compareTo("10") >= 0 && temp.compareTo("25") <= 0 ? a + b : a;
            b = a;
            a = c;
        }
        return a;
    }
}
